<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@include file="/WEB-INF/pages/include/prelude.jspf"%>
<%@include file="/WEB-INF/pages/include/common.jspf"%>
<link href="<c:url value='/static/css/mobiscroll.custom-2.5.2.min.css' />" type="text/css" rel="stylesheet"/>
<link href="<c:url value='/static/css/memberInfo.css' />" type="text/css" rel="stylesheet"/>
<title>会员注册</title>
<style type="text/css">

</style>
<script type="text/javascript" src="<c:url value='/static/js/jQuery.Hz2Py-min.js' />"></script>
<script type="text/javascript" src="<c:url value='/static/js/mobiscroll.custom-2.5.2.min.js' />"></script>
<script type="text/javascript" src="<c:url value='/static/js/validate.js' />"></script>

<script type="text/javascript">
function initValidate(){
	$('#birthday').mobiscroll().date({
        theme: 'jqm',
        display: 'modal',
        mode: 'clickpick', //mixed //scroller //clickpick
        invalid: [ 'w0', 'w6', '5/1', '12/24', '12/25' ],
        setText: '确定',
        cancelText: '取消',
        dateOrder:'yymmdd',
        dayText: '日', monthText: '月', yearText: '年'
    });
	$("#cNLastName").blur(function(){
		var val =  $(this).toPinyin().toUpperCase();
		$("#lastName").val(replaceSpace(val));
	});
	$("#cNFirstName").blur(function(){
		var val =  $(this).toPinyin().toUpperCase();
		$("#firstName").val(replaceSpace(val));
	});
}
$(function(){
	initValidate();
	$("#pagetitle").html('会员创建');
	var msg = "${msg}";
	if(msg!=""){
		alert(msg);
	}
});
	/**
	 * 表单验证
	 */
	function submitForm() {
		var cNLastName =  $("#cNLastName").val();
		var cNFirstName =  $("#cNLastName").val();
		if(cNLastName.length>4&&cNFirstName.trim()!=''){
			alert("对不起，中文姓最多4个汉字！");
			return false;
		}
		if(cNFirstName.length>4&&cNFirstName.trim()!=''){
			alert("对不起，中文名最多4个汉字！");
			return false;
		}
		if (!IsNull('lastName', '英文姓'))
			return false;
		if (!checkLength('lastName', '英文姓',50))
			return false;
		if (!IsNull('firstName', '英文名'))
			return false;
		if (!checkLength('firstName', '英文名',50))
			return false;
		if (!IsNull('birthday', '生日'))
			return false;
		if (!IsNull('credentialType', '证件类型'))
			return false;
		if (!IsNull('credentialNum', '证件号'))
			return false;
		if (!checkLength('credentialNum', '证件号',50))
			return false;
		var credentialType = $("#credentialType").val();
		if (credentialType == 'ID Card') {
			if (!IsCard('credentialNum', '身份证号')) {
				return false;
			}else{
				var csr = $("#credentialNum").val().substring(6, 14);
				var sr = $("#birthday").val();
				csr = csr.substring(4,6).toString()+"/"+csr.substring(6,8).toString()+"/"+ csr.substring(0,4).toString();
				if(csr!=sr){
					alert("对比起，身份证必须与生日相同！");
					return false;
				}
			}
		}
		if (!IsNull('nationality', '国籍'))
			return false;
		if (!IsNull('phoneNum', '手机号码'))
			return false;
		if (!IsPhone('phoneNum', '手机号码'))
			return false;
		if (!checkLength('phoneNum', '手机号码',100))
			return false;
		if (!IsNull('pin', '密码'))
			return false;
		var pin = $("#pin").val();
		if (pin.length == 6) {
			var re = /^[0-9]*[1-9][0-9]*$/;
			var result = TestRgexp(re, pin); //测试 返回true或false 
			if (!result) {
				alert("对不起，密码长度必须为6位数字");
				return false;
			}
		} else if(pin.length != 6){
			alert("对不起，密码长度必须为6位数字");
			return false;
		}
		if(checkWeakPassword(pin)){
			alert("对不起，密码过于简单！");
			return false;
		}
		var pin1 = $("#pin1").val();
		if (!IsNull('pin1', '确认密码'))
			return false;
		if (pin1 != pin) {
			alert("对不起，确认密码必须与密码不一致！");
			return false;
		}
		if (!IsEmail('emailAddr', '电子邮箱'))
			return false;
		if (!checkLength('emailAddr', '电子邮箱',100))
			return false;
		if (!IsZIP('postalCode', '邮编'))
			return false;
		if (!checkLength('company', '公司',100))
			return false;
		if (!checkLength('department', '部门',100))
			return false;
		if (!checkLength('street', '地址',200))
			return false;
		alert("验证通过,可以提交。");
		$("#form").submit();
	}
</script>
</head>
<body>
<div data-role="page">
	<%@include file="/WEB-INF/pages/include/header.jsp"%>
	<div data-role="content">
	<form id="form" action="<c:url value='/member/addMemberCreate.do' />" method="post" data-ajax="false">
		<div class="m_item">
			<div class="m_title">会员基础信息</div>
			<ul>
				<li><div class="i_label"><span class="xh"></span>中文姓：</div><input data-role="none" id="cNLastName" value="" name="cNLastName" type="text" class="txt" /><div class="clear"></div></li>
				<li><div class="i_label"><span class="xh"></span>中文名：</div><input data-role="none" id="cNFirstName" value="" name="cNFirstName" type="text" class="txt" /><div class="clear"></div></li>
				<li><div class="i_label"><span class="xh">*</span>英文姓：</div><input data-role="none" id="lastName" value="" name="lastName" type="text" class="txt" /><div class="clear"></div></li>
				<li><div class="i_label"><span class="xh">*</span>英文名：</div><input data-role="none" id="firstName" value="" name="firstName" type="text" class="txt" /><div class="clear"></div></li>
				<li>
					<div class="i_label"><span class="xh">*</span>性别：</div>
				        <input data-role="none" type="radio" name="gender" id="radio-view-a" value="M" class="radio" checked />
			         	<label for="radio-view-a" class="radio">男</label>
			         	<input data-role="none" type="radio" name="gender" id="radio-view-b" value="F" class="radio"  />
			         	<label for="radio-view-b" class="radio">女</label>
					<div class="clear"></div>
				</li>
				<li><div class="i_label"><span class="xh">*</span>生日：</div>
					<input data-role="none" name="birthday" id="birthday" class="txt" />
					<div class="clear"></div>
				</li>
				<li><div class="i_label"><span class="xh">*</span>证件类型：</div>
					<select data-role="none" name="credentialType" id="credentialType" onchange="$(this).blur()" class="txt" >
						<option value="ID Card">身份证</option>
						<option value="Taiwan_Permit">入台证</option>
						<option value="U.N._Passport">联合国护照</option>
						<option value="Official_Passport">公务护照</option>
						<option value="HK_Macao_Permit">港澳通行证</option>
						<option value="Offical_HK_Macao">公务港澳通行证</option>
						<option value="Officer_Certification">军官证</option>
						<option value="Taiwan_ID">台胞证</option>
						<option value="Reentry_Permit">回乡证</option>
						<option value="Ordinary_Passport">普通护照</option>
						<option value="Others">其他</option>
					</select>	
					<div class="clear"></div>
				</li>
				<li><div class="i_label"><span class="xh">*</span>证件号：</div><input data-role="none" id="credentialNum" name="credentialNum" value="" type="text" class="txt" /><div class="clear"></div></li>
				<li><div class="i_label"><span class="xh">*</span><span>国籍：</span></div>
					<select data-role="none" name="nationality" id="nationality" onchange="$(this).blur()" class="txt">
						<option>国内</option>
						<option>国外</option>
					</select>
					<div class="clear"></div>
				</li>
				<li><div class="i_label"><span class="xh"></span><span>国家/地区：</span></div>
					<select data-role="none" name="country" id="country" onchange="$(this).blur()" class="txt">
						<option></option>
						<option></option>
					</select>	
					<div class="clear"></div>
				</li>
				<li><div class="i_label"><span class="xh"></span><span>省/州：</span></div>
					<select data-role="none" name="state" id="state" onchange="$(this).blur()" class="txt">
						<option></option>
						<option></option>
					</select>	
					<div class="clear"></div>
				</li>
				<li><div class="i_label"><span class="xh"></span><span>城市/县：</span></div>
					<select data-role="none" name="city" id="city" onchange="$(this).blur()" class="txt">
						<option></option>
						<option></option>
					</select>	
					<div class="clear"></div>
				</li>
				<li><div class="i_label"><span class="xh">*</span>手机号码：</div><input data-role="none" id="phoneNum" value="" name="phoneNum" type="text" class="txt" /><div class="clear"></div></li>
				<li><div class="i_label"><span class="xh">*</span>密码：</div><input data-role="none" id="pin" name="pin" value="" type="password" class="txt" /><div class="clear"></div></li>
				<li><div class="i_label"><span class="xh">*</span>确认密码：</div><input data-role="none" id="pin1" name="pin1" value="" type="password" class="txt" /><div class="clear"></div></li>
				
			</ul>
			<div class="m_title" style="margin-top:10px;">会员额外信息</div>
			<ul>
				<li><div class="i_label"><span class="xh"></span>电子邮箱：</div><input data-role="none" id="emailAddr" value="" name="emailAddr" type="text" class="txt" /><div class="clear"></div></li>
				<li><div class="i_label"><span class="xh"></span>联系语言：</div>
					<input data-role="none" type="radio" name="language" id="radio-view-a" value="CN" class="radio" checked />
		         	<label for="radio-view-a" class="radio">中文</label>
		         	<input data-role="none" type="radio" name="language" id="radio-view-b" value="EN" class="radio"  />
		         	<label for="radio-view-b" class="radio">英文</label>
					<div class="clear"></div>
				</li>
				<li><div class="i_label"><span class="xh"></span>邮编：</div><input data-role="none" id="postalCode" value="" name="postalCode" type="text" class="txt" /><div class="clear"></div></li>
				<li><div class="i_label"><span class="xh"></span>公司：</div><input data-role="none" id="company" value="" name="company" type="text" class="txt" /><div class="clear"></div></li>
				<li><div class="i_label"><span class="xh"></span>部门：</div><input data-role="none" id="department" value="" name="department" type="text" class="txt" /><div class="clear"></div></li>
				<li><div class="i_label"><span class="xh"></span>地址：</div><input data-role="none" id="street" value="" name="street" type="text" class="txt" /><div class="clear"></div></li>
			</ul>
		</div>
		<br />
		<div>
			<button class="btn" onclick="submitForm();" data-theme="f" type="button">注册</button>
		</div>
	  </form>
	</div>
</div>
</body>
</html>